package com.y.mytest.jm;

import com.y.mytest.jm.aes.AESUtils;

import java.nio.charset.StandardCharsets;
import java.util.Arrays;

/**
 * @ClassName: test2
 * @author: 叶子豪
 * @create: 2021-03-30 09:30
 */
public class test2 {
    public static void main(String[] args) throws Exception {
        String data = "{ \"qr_token\": \"123456\", " +
                "    \"qr_validity_start\": \"2021-12-11T15:30:00Z\",\n" +
                "    \"qr_validity_end\": \"2021-03-31T17:31:18+01:00\",\n" +
                "    \"qr_validity_serials\": [ \"12321SS49H4L\",\"12321SS2EDGG\"],\n" +
                "    \"qr_areas\": [1, 2] }";
        byte[] compressData = ZlibTest.compress(data.getBytes());
        String zlib = new String(compressData);

        System.out.println("y压缩后的字节流：" + Arrays.toString(compressData));
        System.out.println("压缩后的字符串：" + zlib);
        System.out.println("压缩后的字节流：" + Arrays.toString(zlib.getBytes()));

        byte[] encrypt = AESUtils.encrypt2(compressData);
        String encryptStr = new String(encrypt);
        System.out.println("y加密的字节流：" + Arrays.toString(encrypt));

        System.out.println("加密字符串：" + encryptStr);
        System.out.println("加密后的字节流：" + Arrays.toString(encryptStr.getBytes(StandardCharsets.ISO_8859_1)));

        System.out.println("y解密后的字节流：" + Arrays.toString(AESUtils.decrypt2(encrypt)));
        String decrypt = new String(AESUtils.decrypt2(encrypt), StandardCharsets.ISO_8859_1);

        System.out.println("解压：" + ZlibTest.decompress(decrypt));
    }

}
